package ar.uba.fi.taller2.ftrs.common;

import java.io.*;



public class Parameters {
	private String path;
	private String name;
	
	static private Parameters parametros =null;
	
	private Parameters() {
		this.setPath("./var/");
		this.setName("Parametros.dat");
	
	}
public static Parameters getParametros(){
	if (parametros == null ) {
		parametros =new Parameters ();
	}
	return parametros;
	
}

public String getMessage(String type,Integer clave){
		String str=new String();
		str =readFile(type,clave);
		
		
		return str;
	}

	private String readFile(String type, Integer clave) {
			   // StringBuilder contents = new StringBuilder();
			    
			    try {
			       BufferedReader input =  new BufferedReader(new FileReader(path+name));
			      try {
			        String line = null; 

			        while (( line = input.readLine()) != null){
			          if (line.contains(type+"\u0009"+clave.toString()))
			         return line.replaceAll(type+"\u0009"+clave.toString()+"\u0009", "");
			        }
			      }
			      finally {
			        input.close();
			      }
			    }
			    catch (IOException ex){
			      ex.printStackTrace();
			    }
			    
			  return "";
			  
		
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	};
	
	
}
